package com.puzzlebazar.client.main.control;

import com.google.gwt.user.client.Window;

public abstract class SubControllerImpl extends GenericControllerImpl {

	private String confirmLeaveState = null;
	
	protected final GenericController parentController;

	/**
	 * Creates a subcontroller
	 * 
	 * @param parentController The parent of this sub controller
	 */
	protected SubControllerImpl( GenericController parentController ) {
		this.parentController = parentController;
	}
	
	@Override
	public boolean confirmLeaveState() {
		if( confirmLeaveState == null ) return true;		
		return Window.confirm( confirmLeaveState );		
	}

	@Override
	public void setConfirmStateChange(String confirmLeaveState) {
		this.confirmLeaveState = confirmLeaveState;
		parentController.setConfirmStateChange( confirmLeaveState );
	}
	

	@Override
	public void backToPreviousState() {
		parentController.backToPreviousState();
	}


	@Override
	public void forwardToPreviousState() {
		parentController.forwardToPreviousState();
	}

	@Override
	public void reloadCurrentState() {
		parentController.reloadCurrentState();
	}

	
}
